<template>
  <transition name="fade">
    <div class="message" :class="type" v-if="visible" :style="{'top':top,'left':left}">
      <i class="icon-type iconfont" :class="'icon-'+type"></i>
      <div class="content" :class="{'hasClose':hasClose}">{{content}}
        <i v-if="hasClose" class="btn-close iconfont icon-close" @click="visible=false"></i>
      </div>
    </div>
  </transition>
</template>

<script>
/*let type = ['info','success','warning','error'];*/

export default {
  name: "MyMessage",
  data() {
    return {
      content: "",
      time: 3000,
      visible: false,
      type: "warning",
      hasClose: false,
      top: "",
      left: ""
    };
  },
  mounted() {
    this.close();
  },
  methods: {
    close() {
      window.setTimeout(() => {
        this.visible = false;
      }, this.time);
    }
  }
};
</script>
